#include"ring.hpp"

void *customer(void*arg)
{
  auto rq=(RingQueue<int>*)arg;
  while(true)
  {
    sleep(1);
    int data=0;
    rq->pop(data);
    cout<<"customer "<<"消费 "<<data<<endl;
  } 
} 
void *producter(void*arg)
{
  auto rq=(RingQueue<int>*)arg;
  while(true)
  {
    int data=rand()%100+1;
    rq->push(data);
    cout<<"producter "<<" 生产 "<<data<<endl;
  }
}

int main()
{
  srand((unsigned long)time(nullptr));
  RingQueue<int>*rq=new RingQueue<int>();
  pthread_t tid1,tid2;
  pthread_create(&tid1,nullptr,customer,(void *)rq);
  pthread_create(&tid2,nullptr,producter,(void *)rq);

  pthread_join(tid1,nullptr);
  pthread_join(tid2,nullptr);

  return 0;
}

